package com.new2i.action;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.new2i.model.DoctorEntity;
import com.new2i.model.ScreenQuarterEntity;
import com.new2i.service.able.ScreenQuarterService; 
import com.new2i.util.Collection2JsonUtil;

/**
 * 筛查学校相应接口
 * 
 * @since 2015/09/04
 * @author 2i
 *
 */
@Controller
@RequestMapping("api/quarter")
public class QuarterApiAction extends BaseAction {

	@Autowired
	private transient ScreenQuarterService mScreenQuarterService;

	/**
	 * 创建筛查医生
	 * 
	 * @author 2i
	 * @since 2015/09/22
	 * @param request
	 * @param response
	 * @param scQuarter
	 */
	@RequestMapping("/create.action")
	public void createScreenQuarter(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenQuarterEntity scQuarter) { 
		HashMap<String, Object> map = mScreenQuarterService.insertScreenQuarter(scQuarter);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
	
	/**
	 * 筛查医生列表
	 * 
	 * @author 2i
	 * @since 2015/09/22
	 * @param request
	 * @param response
	 * @param scQuarter
	 */
	@RequestMapping("/list.action")
	public void selectScreenQuarterList(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenQuarterEntity scQuarter) {
		List<HashMap<String, Object>> list = mScreenQuarterService.selectScreenQuarterList(doctor);
		String value = Collection2JsonUtil.byList(list, "sc_quarter_list");
		write2client(response, value);
	}
	
	/**
	 * 筛查医生列表
	 * 
	 * @author 2i
	 * @since 2015/09/22
	 * @param request
	 * @param response
	 * @param scQuarter
	 */
	@RequestMapping("/info.action")
	public void getScreenQuarterInfo(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenQuarterEntity scQuarter) {
		HashMap<String, Object> map = mScreenQuarterService.getScreenQuarterById(scQuarter);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
	

	
	/**
	 * 修改筛查医生
	 * 
	 * @author 2i
	 * @since 2015/09/22
	 * @param request
	 * @param response
	 * @param scQuarter
	 */
	@RequestMapping("/update.action")
	public void updateScreenQuarter(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenQuarterEntity scQuarter) {
		HashMap<String, Object> map = mScreenQuarterService.updateScreenQuarter(scQuarter);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
	
	/**
	 * 已移除（软删除）筛查医生
	 * 
	 * @author 2i
	 * @since 2015/09/24
	 * @param request
	 * @param response
	 * @param scQuarter
	 */
	@RequestMapping("/remove.action")
	public void removeScreenQuarter(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenQuarterEntity scQuarter) {
		HashMap<String, Object> map = mScreenQuarterService.removeScreenQuarter(scQuarter);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
	
	
	/**
	 * 删除筛查季度
	 * 
	 * @author 2i
	 * @since 2015/09/24
	 * @param request
	 * @param response
	 * @param scQuarter
	 */
	@RequestMapping("/delete.action")
	public void deleteScreenQuarterList(HttpServletRequest request, HttpServletResponse response,DoctorEntity doctor,
			ScreenQuarterEntity scQuarter) {
		HashMap<String, Object> map = mScreenQuarterService.deleteScreenQuarter(scQuarter);
		String value = Collection2JsonUtil.byObject(map);
		write2client(response, value);
	}
}
